@extends('admin.main')

@section('content')
<div class="wrapper wrapper-content">
    <div class="ibox">
        <div class="ibox-title">
            <h5>用户</h5>
        </div>
        <div class="ibox-content">
            <div class="table-responsive">
                 <form role="form" class="form-inline">
                    <div class="form-group">
                        <select class="form-control" name="sex">
                            <option value="0">---请选择性别---</option>
                            <option value="1">男</option>
                            <option value="2">女</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <input type="text" name="number" placeholder="会员编号" class="form-control">
                    </div>
                    <div class="form-group">
                        <input type="text" name="weixin" placeholder="微信号" class="form-control">
                    </div>
                    <button type="submit" class="btn btn-white">搜索</button>
                </form>
                <div class="hr-line-dashed"></div>
                <table id="tblDataList" class="table table-striped table-bordered">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>会员编号</th>
                            <th>微信昵称</th>
                            <th>备注</th>
                            <th>微信号</th>
                            <th>累计消费</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach($rows as $k=>$row)
                        <tr data-wechat="{{$row->id}}">
                            <td class="text-center">
                                {{$k+1}}
                            </td>
                            <td>{{$row->number}}</td>
                            <td>{{$row->nickname}}</td>
                            <td>{{$row->memo_name ? $row->memo_name :'暂无备注'}}&nbsp;&nbsp;<button type="button" class="btn btn-primary btn-xs btn-update">修改备注</button></td>
                            <td>{{$row->weixin}}</td>
                            <td>{{$row->count}}</td>
                            <td>
                                <a href="javascript:;" class="m-r-xs btn btn-primary btn-xs btn-user-info">查看
                                </a>
                            </td>
                        </tr>
                        @endforeach
                    </tbody>
                </table>
                <div class="text-center"><?php echo $rows->render(); ?></div>
            </div>
        </div>
    </div>
</div>

@include('admin.user.templateUserinfo')
@endsection

@section('pagescript')
<script>
    $("#side-menu li[rel='vip']").addClass("active");

    $(function(){
        $('.btn-update').click(function(){
            id = $(this).parents('tr').eq(0).attr('data-wechat');
            layer.prompt({title: '修改备注', formType: 0}, function(text, index){
                var formdata = {'memo_name':text,'id':id};
                $.post("/admin/user/info/update", formdata, function(){
                    layer.msg('修改成功');
                    window.location.reload();
                }).fail(failure);
            });
        });
        $('.btn-user-info').click(function(){
            var id=  $(this).parents('tr').eq(0).attr('data-wechat');
            $.get('/admin/user/info/'+id,function(data){
                $("#modalDialog").html(template("tplUserInfo", data)).modal("show");
            }).fail(failure);
        });
    })

</script>
@endsection
